package com.udistrital.udcajbweb.adminMenu.web.bean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;

import com.udistrital.framework.adminMenu.DTO.MenuDTO;
import com.udistrital.framework.adminMenu.modelo.Amusr;
import com.udistrital.framework.servicio.ejb.AdminMenuEJBeanLocal;
import com.udistrital.udcajbweb.comun.web.bean.BaseBean;

/**
 * Bean gestionado del menu
 * @author nrodriguez
 * @version 1.0 30-01-2012
 *
 */
public class MenuBean extends BaseBean {

	private static final long serialVersionUID = -3442342899667481873L;
	
	
	@EJB
	private AdminMenuEJBeanLocal adminMenuEJBeanLocal;
	
	private List<MenuDTO> listMenu = new ArrayList<MenuDTO>();
	private HashMap<Integer, Boolean> menueState=new HashMap<Integer, Boolean>();
	
	
	@PostConstruct
	public void init() {
		Amusr amusr = (Amusr)super.getHttpSession().getAttribute("usuario");
		if(amusr != null && amusr.getAprnom() != null){
			setListMenu(adminMenuEJBeanLocal.getMenu(amusr, 1));
		}		
	}
	
	/**
	 * Metodo que retorna la navegacion desde la base de datos
	 * @return String navegacion
	 */
	public String navegacion(){		
		String url = super.getRequestParameter("url");
//		url = "#{amusrListaBean.init}";
		return url;		
	}

	public List<MenuDTO> getListMenu() {
		return listMenu;
	}

	public void setListMenu(List<MenuDTO> listMenu) {
		this.listMenu = listMenu;
	}

	/**
	 * @return the adminMenuEJBeanLocal
	 */
	public AdminMenuEJBeanLocal getAdminMenuEJBeanLocal() {
		return adminMenuEJBeanLocal;
	}

	/**
	 * @param adminMenuEJBeanLocal the adminMenuEJBeanLocal to set
	 */
	public void setAdminMenuEJBeanLocal(AdminMenuEJBeanLocal adminMenuEJBeanLocal) {
		this.adminMenuEJBeanLocal = adminMenuEJBeanLocal;
	}

	public HashMap<Integer, Boolean> getMenueState() {
		return menueState;
	}

	public void setMenueState(HashMap<Integer, Boolean> menueState) {
		this.menueState = menueState;
	}
	
}